//============================================================================================
/**
 * @file	box2_tp.c
 * @brief	新ボックス画面 タッチパネル関連
 * @author	Hiroyuki Nakamura
 * @date	08.05.30
 */
//============================================================================================
#include "common.h"

#include "gflib/touchpanel.h"

#include "box2_main.h"
#include "box2_obj.h"
#include "box2_tp.h"


//============================================================================================
//	定数定義
//============================================================================================
#define	TRAYPOKE_SX		( BOX2OBJ_TRAYPOKE_SX )						// トレイのポケモンのタッチ範囲サイズＸ
#define	TRAYPOKE_SY		( 24 )										// トレイのポケモンのタッチ範囲サイズＹ
#define	TRAYPOKE_PX		( BOX2OBJ_TRAYPOKE_PX - TRAYPOKE_SX / 2 )	// トレイのポケモンのタッチ開始座標Ｘ
#define	TRAYPOKE_PY		( 40 )										// トレイのポケモンのタッチ開始座標Ｙ


//============================================================================================
//	プロトタイプ宣言
//============================================================================================


//============================================================================================
//	グローバル変数
//============================================================================================

// タッチ座標テーブル：トレイのポケモン
static const RECT_HIT_TBL TrayPokeHitTbl[] =
{
	{ TRAYPOKE_PY+TRAYPOKE_SX*0, TRAYPOKE_PY+TRAYPOKE_SY*1-1, TRAYPOKE_PX+TRAYPOKE_SX*0, TRAYPOKE_PX+TRAYPOKE_SX*1-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*0, TRAYPOKE_PY+TRAYPOKE_SY*1-1, TRAYPOKE_PX+TRAYPOKE_SX*1, TRAYPOKE_PX+TRAYPOKE_SX*2-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*0, TRAYPOKE_PY+TRAYPOKE_SY*1-1, TRAYPOKE_PX+TRAYPOKE_SX*2, TRAYPOKE_PX+TRAYPOKE_SX*3-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*0, TRAYPOKE_PY+TRAYPOKE_SY*1-1, TRAYPOKE_PX+TRAYPOKE_SX*3, TRAYPOKE_PX+TRAYPOKE_SX*4-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*0, TRAYPOKE_PY+TRAYPOKE_SY*1-1, TRAYPOKE_PX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, TRAYPOKE_PX+TRAYPOKE_SX*5-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*3, TRAYPOKE_PY+TRAYPOKE_SY*4-1, TRAYPOKE_PX+TRAYPOKE_SX*5, TRAYPOKE_PX+TRAYPOKE_SX*6-1 },

	{ TRAYPOKE_PY+TRAYPOKE_SX*4, TRAYPOKE_PY+TRAYPOKE_SY*5-1, TRAYPOKE_PX+TRAYPOKE_SX*0, TRAYPOKE_PX+TRAYPOKE_SX*1-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*4, TRAYPOKE_PY+TRAYPOKE_SY*5-1, TRAYPOKE_PX+TRAYPOKE_SX*1, TRAYPOKE_PX+TRAYPOKE_SX*2-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*4, TRAYPOKE_PY+TRAYPOKE_SY*5-1, TRAYPOKE_PX+TRAYPOKE_SX*2, TRAYPOKE_PX+TRAYPOKE_SX*3-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*4, TRAYPOKE_PY+TRAYPOKE_SY*5-1, TRAYPOKE_PX+TRAYPOKE_SX*3, TRAYPOKE_PX+TRAYPOKE_SX*4-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*4, TRAYPOKE_PY+TRAYPOKE_SY*5-1, TRAYPOKE_PX+TRAYPOKE_SX*4, TRAYPOKE_PX+TRAYPOKE_SX*5-1 },
	{ TRAYPOKE_PY+TRAYPOKE_SX*4, TRAYPOKE_PY+TRAYPOKE_SY*5-1, TRAYPOKE_PX+TRAYPOKE_SX*5, TRAYPOKE_PX+TRAYPOKE_SX*6-1 },

	{ RECT_HIT_END, 0, 0, 0 }
};

// タッチ座標テーブル：手持ちポケモン（左）
static const RECT_HIT_TBL PartyPokeLeftHitTbl[] =
{
	{  68-12,  68+12-1, 42-12, 42+12-1 }, {  76-12,  76+12-1, 78-12, 78+12-1 },
	{ 100-12, 100+12-1, 42-12, 42+12-1 }, { 108-12, 108+12-1, 78-12, 78+12-1 },
	{ 132-12, 132+12-1, 42-12, 42+12-1 }, { 140-12, 140+12-1, 78-12, 78+12-1 },

	{ RECT_HIT_END, 0, 0, 0 }
};

// タッチ座標テーブル：手持ちポケモン（右）
static const RECT_HIT_TBL PartyPokeRightHitTbl[] =
{
	{  68-12,  68+12-1, 194-12, 194+12-1 }, {  76-12,  76+12-1, 230-12, 230+12-1 },
	{ 100-12, 100+12-1, 194-12, 194+12-1 }, { 108-12, 108+12-1, 230-12, 230+12-1 },
	{ 132-12, 132+12-1, 194-12, 194+12-1 }, { 140-12, 140+12-1, 230-12, 230+12-1 },

	{ RECT_HIT_END, 0, 0, 0 }
};


//--------------------------------------------------------------------------------------------
/**
 * タッチチェック：トレイのポケモン
 *
 * @param	none
 *
 * @return	RECT_HIT_NONE = 触っていない
 */
//--------------------------------------------------------------------------------------------
u32 BOX2TP_HitTrayPokeTrg(void)
{
	return GF_TP_RectHitTrg( TrayPokeHitTbl );
}

//--------------------------------------------------------------------------------------------
/**
 * タッチチェック：手持ちポケモン（左）
 *
 * @param	none
 *
 * @return	RECT_HIT_NONE = 触っていない
 */
//--------------------------------------------------------------------------------------------
u32 BOX2TP_HitCheckTrgPartyPokeLeft(void)
{
	return GF_TP_RectHitTrg( PartyPokeLeftHitTbl );
}

//--------------------------------------------------------------------------------------------
/**
 * タッチチェック：手持ちポケモン（右）
 *
 * @param	none
 *
 * @return	RECT_HIT_NONE = 触っていない
 */
//--------------------------------------------------------------------------------------------
u32 BOX2TP_HitCheckTrgPartyPokeRight(void)
{
	return GF_TP_RectHitTrg( PartyPokeRightHitTbl );
}